//
//  ChoseHeaderView.m
//  ManyCollectionView
//
//  Created by apple on 16/7/14.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ChoseHeaderView.h"
#define WIDTH [[UIScreen mainScreen] bounds].size.width
#define HEIGHT [[UIScreen mainScreen] bounds].size.height
@implementation ChoseHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        
        NSArray *nameArr = @[@"综合",@"销量",@"价格"];

        for (int i = 0; i < 3; i ++) {
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.tag =  200 + i;
            button.backgroundColor = [UIColor whiteColor];
            [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            button.frame = CGRectMake(WIDTH/3 * i, 0, WIDTH/3, 50);
            [button addTarget:self action:@selector(touchUpAction:) forControlEvents:UIControlEventTouchUpInside];
            [button setTitle:nameArr[i] forState:UIControlStateNormal];
            [button setImage:[UIImage imageNamed:@"SX_1"] forState:UIControlStateNormal];
            button.titleEdgeInsets = UIEdgeInsetsMake(10,10,10,20);
            button.imageEdgeInsets = UIEdgeInsetsMake(12,WIDTH/3 - 30,12,0);
            [self addSubview:button];
        }
        
        for (int l = 0; l < 2; l ++) {
            UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/3 * (l + 1), 2, 0.5, 50 - 4)];
            line.backgroundColor = [UIColor colorWithRed:143/255.0 green:141/255.0 blue:143/255.0 alpha:1];
            [self addSubview:line];
        }
        
        
        
    }
    return self;
}

- (void)touchUpAction:(UIButton *)sender {
    if (sender.tag == 200) {
        NSLog(@"1");
    }else if (sender.tag == 201) {
        NSLog(@"2");
    }else {
        NSLog(@"3");
    }
}





@end
